package com.ss.android.article.base.feature.update.b;

import android.view.View;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.account.Spipe;
import com.ss.android.article.base.feature.update.a.UserInfo;
import com.ss.android.article.base.feature.update.a.b;
import com.ss.android.article.browser.R;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.newmedia.BaseAppData;

final class i implements View.OnClickListener {
    private final d a;

    i(d arg1) {
        this.a = arg1;

    }

    public final void onClick(View arg12) {
        if (this.a.u != null) {
            if (arg12.getId() == R.id.acx) {
                this.a.a("top_digg_click");
            }

            b v0 = new b(0);
            v0.b = this.a.u.i;
            boolean v1 = this.a.u.a;
            this.a.u.a = true;
            d v3 = this.a;
            int v4 = this.a.u.b;
            if (v3.w == null) {
                return;
            }

            v0.i = v1;
            v3.o.setText(UIUtils.a(v4));
            if (!v0.i) {
                v3.o.onDiggClick();
            }

            d.d$a v3_1 = v3.w;
            if (!v3_1.a.isViewValid()) {
                return;
            }

            if (v3_1.a.j == null) {
                return;
            }

            if (v3_1.a.a == null) {
                return;
            }

            if (v0.i) {
                v3_1.a.b(com.ss.android.article.browser.R.string.update_toast_digged);
                return;
            }

            new com.ss.android.article.base.feature.update.b.b(v3_1.a.a, v0).start();
            Spipe v0_1 = Spipe.inst();
            if (v0_1.isLogin) {
                UserInfo v4_1 = new UserInfo(v0_1.userId);
                v4_1.screenName = v0_1.screenName;
                v4_1.avatarUrl = v0_1.avatarUrl;
                v4_1.userVerified = v0_1.userVerified;
                com.ss.android.article.base.feature.update.a.d v5 = v3_1.a.j;
                int v1_1 = 0;
                while (true) {
                    if (v1_1 < v5.p.g.size()) {
                        Object v0_2 = v5.p.g.get(v1_1);
                        if (((UserInfo) v0_2).userId == v4_1.userId) {
                            v5.p.g.remove(v1_1);
                            v5.p.g.add(0, v0_2);
                        } else {
                            ++v1_1;
                            continue;
                        }
                    } else {
                        ++v5.b;
                        ++v5.p.d;
                        v5.p.g.add(0, v4_1);
                    }
                    break;
                }
            } else {
                ++v3_1.a.j.b;
            }

            label_90:
            if (v3_1.a.e > 0) {
                CallbackCenter.notifyCallback(BaseAppData.callbackTypeCommentExtraInfoChanged, new Object[]{BaseAppData.callbackTypeCommentExtraInfoChanged, Long.valueOf(v3_1.a.e), Integer.valueOf(v3_1.a.j.c), Integer.valueOf(v3_1.a.j.b), Boolean.valueOf(true)});
            }

            if (v3_1.a.a != null) {
                UpdateItemMgr.getInstance(v3_1.a.a).b(v3_1.a.j);
            }

            v3_1.a.c();
        }
    }
}

